﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DTO;

namespace DAO
{
    public class dichvu_DAO
    {
        public static DataSet loadthongtinhoadondvvaolistview(hoadondv_DTO hddv)
        {
            string sql = "select mahddv,tendv,map,makh,soluong,ngaydat,thanhtien from hoadondv hd,dichvu dv where hd.madv =dv.madv and makh='" + hddv.makh + "'";
            DataSet ds=new DataSet();
            ds=dataconnect.laydulieu(sql);
            return ds;
        }
        public static DataSet loadthongtindvtheomap(string map)
        {
            string sql = "select * from hoadondv where map='"+map+"'";
            DataSet ds = new DataSet();
            ds = dataconnect.laydulieu(sql);
            return ds;
        }
        public static bool themdv(hoadondv_DTO hddv)
        {
            string sql = "insert into hoadondv(madv,map,makh,soluong,ngaydat,thanhtien) values('"+hddv.madv+"',"+hddv.map+",'"+hddv.makh+"',"+hddv.soluong+",'"+hddv.ngaydat+"',"+hddv.thanhtien+")";
            return dataconnect.xulycaulenh(sql);
        }
        public static bool xoadv(hoadondv_DTO hddv)
        {
            string sql = "delete from hoadondv where mahddv="+hddv.mahddv+"";
            return dataconnect.xulycaulenh(sql);
        }
        public static bool suadv(hoadondv_DTO hddv)
        {
            string sql = "update hoadondv set madv='"+hddv.madv+"',soluong="+hddv.soluong+",thanhtien="+hddv.thanhtien+",ngaydat='"+hddv.ngaydat+"',map="+hddv.map+" where mahddv="+hddv.mahddv+"";
            return dataconnect.xulycaulenh(sql);
        }
        public static DataSet loadthongtindichvu()
        {
            string sql = "select * from dichvu";
            DataSet ds = new DataSet();
            ds = dataconnect.laydulieu(sql);
            return ds;
        }
        public static DataSet loadmap()
        {
            string sql = "select * from khachhang";
            DataSet ds = new DataSet();
            ds = dataconnect.laydulieu(sql);
            return ds;
        }
        public static DataSet loadtendv()
        {
            string sql = "select * from dichvu";
            DataSet ds = new DataSet();
            ds = dataconnect.laydulieu(sql);
            return ds;
        }
        public static DataSet laydongia(dichvu_DTO dv)
        {
            string sql = "select dongia from dichvu where madv='"+dv.madv+"'";
            DataSet ds = new DataSet();
            ds = dataconnect.laydulieu(sql);
            return ds;
        }
        public static DataSet automahddv()
        {
            string sql = "select top 1 manv from nhanvien order by manv desc";
            DataSet ds = new DataSet();
            ds = dataconnect.laydulieu(sql);
            return ds;
        }
        public static DataSet loaddichvuvaolist()
        {
            string sql = "select * from dichvu";
            DataSet ds = new DataSet();
            ds = dataconnect.laydulieu(sql);
            return ds;
        }
        public static bool themdichvu(dichvu_DTO dv)
        {
            string sql = "insert into dichvu (madv,tendv,dongia) values('"+dv.madv+"','"+dv.tendv+"',"+dv.dongia+")";
            return dataconnect.xulycaulenh(sql);
        }
        public static bool xoadichvu(dichvu_DTO dv)
        {
            string sql = "delete from dichvu where madv='"+dv.madv+"'";
            return dataconnect.xulycaulenh(sql);
        }
        public static bool suadichvu(dichvu_DTO dv)
        {
            string sql = "update dichvu set tendv='"+dv.tendv+"',dongia="+dv.dongia+" where madv='"+dv.madv+"'";
            return dataconnect.xulycaulenh(sql);
        }
    }
}
